﻿using System;
using System.Diagnostics;
using Rerun.Exceptions;

namespace Rerun.Services {

    /// <summary>
    /// 
    /// </summary>
    public class LoggingService {
        private static EventLog eventLog = new EventLog(Properties.Settings.Default.Application);

        /// <summary>
        /// 
        /// </summary>
        /// <exception cref="LoggingException"></exception>
        static LoggingService() {
            try {
                eventLog.Source = Properties.Settings.Default.EventLogSource;
            } catch(Exception e) {
                throw new LoggingException(e.Message);
            }
        }

        /// <summary>
        /// 
        /// </summary>
        private LoggingService() {
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="message"></param>
        /// <param name="entryType"></param>
        /// <exception cref="LoggingException"></exception>
        public static void WriteEventLogEntry(string message, EventLogEntryType entryType) {
            try {
                eventLog.WriteEntry(message, entryType);
            } catch(Exception e) {
                throw new LoggingException(e.Message);
            }
        }
    }
}